import request from "@/utils/request";
import type {AjaxResult,page} from "@/utils/request"

const base = '/base/problem'
/**
 * 获取题目列表
 * @returns Promise
 */
export const getProblemList = (data,params?:page) : Promise<AjaxResult> => {
    return request({
        url: `${base}/list`,
        method: 'post',
        params: params,
        data:data
    })
}

/**
 * 获取最新的题目列表
 * @returns Promise
 */
export const getNewProblemList = () : Promise<AjaxResult> => {
    return request({
        url: `${base}/new/list`,
        method: 'get',
    })
}
/**
 * 获取题目详情
 * @returns Promise
 */
export const getProblemDetail = (id) : Promise<AjaxResult> => {
    return request({
        url: `${base}/${id}`,
        method: 'get',
    })
}

/**
 * 下载单个测试用例
 * @returns Promise
 */
export const downloadTestcase = (pid,id) : Promise<any> => {
    return request({
        url: `${base}/download/problemCase/${pid}/${id}`,
        method: 'get',
        responseType: 'blob',
    })
}
